@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row">
            <div class="panel panel-default">
                <div class="panel-heading">菜单</div>
                <div class="panel-body">
                    <form class="form-horizontal" role="form" method="POST" action="{{ url('menu/save/'.$wechatMenu["id"]) }}">
                        {{ csrf_field() }}

                        <div class="form-group{{ $errors->has('parent_id') ? ' has-error' : '' }}">
                            <label for="parent_id" class="col-md-4 control-label">父菜单</label>
                            <div class="col-md-6">
                                {{ Form::select('parent_id', $firstChilds, $wechatMenu["parent_id"], ["class"=>"form-control"]) }}
                                @if ($errors->has('parent_id'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('parent_id') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
                            <label for="name" class="col-md-4 control-label">菜单名称</label>
                            <div class="col-md-6">
                                <input id="name" type="text" class="form-control" name="name" value="{{ old('name',$wechatMenu["name"]) }}" required>
                                @if ($errors->has('name'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('name') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group{{ $errors->has('typecode') ? ' has-error' : '' }}">
                            <label for="typecode" class="col-md-4 control-label">菜单类型</label>
                            <div class="col-md-6">
                                {{ Form::select('typecode', $menuTypeList, $wechatMenu["typecode"], ["class"=>"form-control"]) }}
                                @if ($errors->has('typecode'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('typecode') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group{{ $errors->has('value') ? ' has-error' : '' }}">
                            <label for="value" class="col-md-4 control-label">值</label>
                            <div class="col-md-6">
                                <textarea id="value" class="form-control" name="value">{{ old('value',$wechatMenu["value"]) }}</textarea>
                                @if ($errors->has('value'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('value') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <button type="submit" class="btn btn-primary">
                                    保存
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection
